package com.clementheliou.cheliou.util.math.average.fest.asserter;

import static org.fest.assertions.api.Assertions.assertThat;

import org.fest.assertions.api.AbstractAssert;

import com.clementheliou.cheliou.util.fest.assertion.CHeliouUtilAssertions;
import com.clementheliou.cheliou.util.math.average.AverageMark;

/**
 * FEST asserter used to make test code about {@link AverageMark} instances more readable. It should
 * only be used through the static factory that can be found into the project assertions class (
 * {@link CHeliouUtilAssertions}).
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link AbstractAssert};
 * @see {@link AverageMark};
 * @see {@link CHeliouUtilAssertions}.
 * @since 1.0
 */
public class AverageMarkAsserter extends AbstractAssert<AverageMarkAsserter, AverageMark> {

	/**
	 * Constructor from the {@link AverageMark} instance to be asserted.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param actual the {@link AverageMark} instance to be asserted.
	 * @since 1.0
	 */
	public AverageMarkAsserter(final AverageMark actual) {
		super(actual, AverageMarkAsserter.class);
	}

	/**
	 * Asserts that the current {@link AverageMark} instance has the expected value.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param expectedValue the expected value for the current {@link AverageMark}.
	 * @return the asserter instance after this assertion.
	 * @since 1.0
	 */
	public AverageMarkAsserter hasValue(final Double expectedValue) {
		isNotNull();
		assertThat(actual.getValue()).isEqualTo(expectedValue);
		return this;
	}

	/**
	 * Asserts that the current {@link AverageMark} instance has the expected marks number.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param expectedMarksNumber the expected marks number for the current {@link AverageMark} .
	 * @return the asserter instance after this assertion.
	 * @since 1.0
	 */
	public AverageMarkAsserter hasMarksNumber(final int expectedMarksNumber) {
		isNotNull();
		assertThat(actual.getMarksNumber()).isEqualTo(expectedMarksNumber);
		return this;
	}
}
